public class contentController1 {

    public contentController1(ApexPages.StandardController controller) {
     file = new ContentVersion();
    }
     public string FileName{ get;set;}
   Id NoteId = ApexPages.currentPage().getParameters().get('Id');
    PageReference pageRef = ApexPages.currentPage();
    Note Mynt = New Note();    
 
    public ContentVersion file { get; set; }         
    
      public PageReference go() {
      if(NoteId != NULL){
        Mynt.ParentId = NoteId;
        Mynt.Title = FileName;
        insert file;     
        insert Mynt;
        Mynt.Body = 'https://ap1.salesforce.com/sfc/#version/'+file.Id;
       update Mynt;
      
     return new PageReference('/' + Mynt.id);
     }
     else if(file.Id !=NULL)
     {
     return pageRef;
     }
     else
     {
     return pageRef;
     }
    }
}